// pages/specific_models/specific_models.js
var api = require('../../api/api');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hidden: true,
    select_displacement_content:"",
    geartype:"",
  
    letters: [ ],
    car_models: [{
      name: '宝马1系'
    }],
    car_data: [],
    new_car_list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var source = options.source;
    this.data.source=source;
    this.getBrands();
  },

  getBrands(){
    api.get('/common/brands').then(res=>{
        this.setData({
          letters:res.items
        })
    });
  },

  //触发全部开始选择
  tStart(e) {
    var showPy = e.currentTarget.dataset.showpy;
    console.log("showPy", showPy)
    this.setData({
      hidden: false,
      showPy: showPy
    })
  },
  //触发结束选择
  tEnd(e) {
    var id = e.currentTarget.dataset.id;

    this.setData({
      hidden: true,
      toView: id,

    })
  },
  //选择品牌
  select_brand(e) {
    var item = e.currentTarget.dataset.item;
    console.log(item)
    var pages = getCurrentPages();
    var currPage = pages[pages.length - 1]; //当前页面
    var prevPage = pages[pages.length - 2];
    prevPage.setData({
      selectBrand:item
    })
    wx.navigateBack({
      delta:1
    })
  },
  //关闭车型
  guanbi_modules() {
    this.setData({
      show_models: false
    })

  },
  //关闭车信息
  guanbi_car_info() {
    this.setData({
      show_car: false,
      gear_index:-1,
      displacement_index:-1
    })

  },

  //选择车型
  select_model(e) {
    var car_name = e.currentTarget.dataset.car_name;
    this.data.car_name = car_name;
    var source = this.data.source;
    if (source == 1) {
      wx.navigateBack({
        
      })
      wx.setStorageSync("car_brand", car_name)
    }else{
    
      var id = e.currentTarget.dataset.id;
      this.data.parentid=id;
      var get_cars = app.ul.get_cars;
      var token = wx.getStorageSync("token");
      var method = 'GET';
      var params = "";
      var url_id = id;
      var car_data = this.data.car_data;
      app.requestData(res => {
        var car_list = res.data.data.list;
        this.data.car_list = car_list;
        this.data.new_car_list=car_list;
        var year_array = [];

        for (let i = 0; i < car_list.length; i++) {
          year_array.push(car_list[i].yeartype)
        }
        year_array = this.arrayToHeavy(year_array)
        year_array.sort();
        year_array.reverse();
        console.log("年份", year_array)
        var data_array = []
        var now_timer = new Date();
        var year = now_timer.getFullYear();
        var year_second = now_timer.setFullYear(year - 1);
        year_second = new Date(year_second).getFullYear();

        var year_third = now_timer.setFullYear(year - 2);
        year_third = new Date(year_third).getFullYear();

        var year_fourth = now_timer.setFullYear(year - 3);
        year_fourth = new Date(year_fourth).getFullYear();

        var year_fiveth = now_timer.setFullYear(year - 4);
        year_fiveth = new Date(year_fiveth).getFullYear();

        var year_sixth = now_timer.setFullYear(year - 5);
        year_sixth = new Date(year_sixth).getFullYear();

        var year_seventh = now_timer.setFullYear(year - 6);
        year_seventh = new Date(year_seventh).getFullYear();

        var year_eighth = now_timer.setFullYear(year - 7);
        year_eighth = new Date(year_eighth).getFullYear();

        var year_ninth = now_timer.setFullYear(year - 8);
        year_ninth = new Date(year_ninth).getFullYear();


        var year_tenth = now_timer.setFullYear(year - 9);
        year_tenth = new Date(year_tenth).getFullYear();


        var year_eleventh = now_timer.setFullYear(year - 10);
        year_eleventh = new Date(year_eleventh).getFullYear();

        var year_twelfth = now_timer.setFullYear(year - 11);
        year_twelfth = new Date(year_twelfth).getFullYear();

        var year_fourteenth = now_timer.setFullYear(year - 12);
        year_fourteenth = new Date(year_fourteenth).getFullYear();

        var year_fifteenth = now_timer.setFullYear(year - 13);
        year_fifteenth = new Date(year_fifteenth).getFullYear();

        var year_sixteenth = now_timer.setFullYear(year - 14);
        year_sixteenth = new Date(year_sixteenth).getFullYear();

        var year_seventeenth = now_timer.setFullYear(year - 15);
        year_seventeenth = new Date(year_seventeenth).getFullYear();

        var year_eighteenth = now_timer.setFullYear(year - 16);
        year_eighteenth = new Date(year_eighteenth).getFullYear();

        var year_nineteenth = now_timer.setFullYear(year - 17);
        year_nineteenth = new Date(year_nineteenth).getFullYear();

        var year_twentieth = now_timer.setFullYear(year - 18);
        year_twentieth = new Date(year_twentieth).getFullYear();

        var year_thirteenth = null;

        console.log(year_second)
        var car_data_item = {
          year: year,
          data: []
        }
        var car_data_item_second = {
          year: year_second,
          data: []
        }
        var car_data_item_third = {
          year: year_third,
          data: []
        }

        var car_data_item_fourth = {
          year: year_fourth,
          data: []
        }
        var car_data_item_fiveth = {
          year: year_fiveth,
          data: []
        }
        var car_data_item_sixth = {
          year: year_sixth,
          data: []
        }
        var car_data_item_seventh = {
          year: year_seventh,
          data: []
        }
        var car_data_item_eighth = {
          year: year_eighth,
          data: []
        }
        var car_data_item_ninth = {
          year: year_ninth,
          data: []
        }
        var car_data_item_tenth = {
          year: year_tenth,
          data: []
        }
        var car_data_item_eleventh = {
          year: year_eleventh,
          data: []
        }
        var car_data_item_twelfth = {
          year: year_twelfth,
          data: []
        }
        var car_data_item_thirteenth = {
          year: year_thirteenth,
          data: []
        }
        var car_data_item_fourteenth = {
          year: year_fourteenth,
          data: []
        }
        var car_data_item_fifteenth = {
          year: year_fifteenth,
          data: []
        }
        var car_data_item_sixteenth = {
          year: year_sixteenth,
          data: []
        }
        var car_data_item_seventeenth = {
          year: year_seventeenth,
          data: []
        }
        var car_data_item_eighteenth = {
          year: year_eighteenth,
          data: []
        }
        var car_data_item_nineteenth = {
          year: year_nineteenth,
          data: []
        }
        var car_data_item_twentieth = {
          year: year_twentieth,
          data: []
        }
        car_data.push(car_data_item)
        car_data.push(car_data_item_second)
        car_data.push(car_data_item_third)
        car_data.push(car_data_item_fourth)
        car_data.push(car_data_item_fiveth)
        car_data.push(car_data_item_sixth)
        car_data.push(car_data_item_seventh)
        car_data.push(car_data_item_eighth)
        car_data.push(car_data_item_ninth)
        car_data.push(car_data_item_tenth)
        car_data.push(car_data_item_eleventh)
        car_data.push(car_data_item_twelfth)
        car_data.push(car_data_item_thirteenth)
        car_data.push(car_data_item_fourteenth)
        car_data.push(car_data_item_fifteenth)
        car_data.push(car_data_item_sixteenth)
        car_data.push(car_data_item_seventeenth)
        car_data.push(car_data_item_eighteenth)
        car_data.push(car_data_item_nineteenth)
        car_data.push(car_data_item_twentieth)

        console.log("car_data", car_data)

        for (let i = 0; i < car_list.length; i++) {
          if (car_list[i].yeartype == year) {
            car_data[0].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_second) {
            car_data[1].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_third) {
            car_data[2].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_fourth) {
            car_data[3].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_fiveth) {
            car_data[4].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_sixth) {
            car_data[5].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_seventh) {
            car_data[6].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_eighth) {
            car_data[7].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_ninth) {
            car_data[8].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_tenth) {
            car_data[9].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_eleventh) {
            car_data[10].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_twelfth) {
            car_data[11].data.push(car_list[i])
          }

          if (car_list[i].yeartype == year_thirteenth) {
            car_data[12].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_fourteenth) {
            car_data[13].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_fifteenth) {
            car_data[14].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_sixteenth) {
            car_data[15].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_seventeenth) {
            car_data[16].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_eighteenth) {
            car_data[17].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_eighteenth) {
            car_data[18].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_nineteenth) {
            car_data[19].data.push(car_list[i])
          }
          if (car_list[i].yeartype == year_twentieth) {
            car_data[20].data.push(car_list[i])
          }
        }
        console.log("car_data", car_data)
        this.setData({
          car_info: res.data.data,
          show_car: true,
          car_data: car_data,
          car_name: car_name
        })
        console.log("此车型的车", res)
      }, get_cars, token, method, params, url_id)
    }
   


  },
  //选择手动，自动挡 筛选
  select_gear(e) {
    var index = e.currentTarget.dataset.index;
    var geartypes = this.data.car_info.geartype;
    var car_list = this.data.car_list;//当前的所有车的数据
    console.log("car_list", car_list);

    var select_displacement_content = this.data.select_displacement_content //排量
    var geartype = geartypes[index].name
    console.log("geartype", geartype)
    if (geartype == "自动") {
      geartype = 1;
    }
    if (geartype == "手动") {
      geartype = 2;
    }

    var gear_index = this.data.gear_index;//手自动挡index
    console.log("gear_index", gear_index)
    var parentid = this.data.parentid;
    var screening_cars = app.ul.screening_cars;
    var token = wx.getStorageSync("token");
    var method = 'GET';
    var params = "";
    var url_id = "?parentid=" + parentid + "&displacement=" + select_displacement_content+ "&geartype=" + geartype
    app.requestData(res => {
      console.log(res)

      var car_list = res.data.data;
      var car_data = [];
      var now_timer = new Date();
      var year = now_timer.getFullYear();
      var year_second = now_timer.setFullYear(year - 1);
      year_second = new Date(year_second).getFullYear();

      var year_third = now_timer.setFullYear(year - 2);
      year_third = new Date(year_third).getFullYear();

      var year_fourth = now_timer.setFullYear(year - 3);
      year_fourth = new Date(year_fourth).getFullYear();

      var year_fiveth = now_timer.setFullYear(year - 4);
      year_fiveth = new Date(year_fiveth).getFullYear();

      var year_sixth = now_timer.setFullYear(year - 5);
      year_sixth = new Date(year_sixth).getFullYear();

      var year_seventh = now_timer.setFullYear(year - 6);
      year_seventh = new Date(year_seventh).getFullYear();

      var year_eighth = now_timer.setFullYear(year - 7);
      year_eighth = new Date(year_eighth).getFullYear();

      var year_ninth = now_timer.setFullYear(year - 8);
      year_ninth = new Date(year_ninth).getFullYear();


      var year_tenth = now_timer.setFullYear(year - 9);
      year_tenth = new Date(year_tenth).getFullYear();


      var year_eleventh = now_timer.setFullYear(year - 10);
      year_eleventh = new Date(year_eleventh).getFullYear();

      var year_twelfth = now_timer.setFullYear(year - 11);
      year_twelfth = new Date(year_twelfth).getFullYear();

      var year_fourteenth= now_timer.setFullYear(year - 12);
      year_fourteenth= new Date(year_fourteenth).getFullYear();

      var year_fifteenth= now_timer.setFullYear(year - 13);
      year_fifteenth = new Date(year_fifteenth).getFullYear();

      var year_sixteenth= now_timer.setFullYear(year - 14);
      year_sixteenth = new Date(year_sixteenth).getFullYear();

      var year_seventeenth= now_timer.setFullYear(year - 15);
      year_seventeenth = new Date(year_seventeenth).getFullYear();

      var year_eighteenth = now_timer.setFullYear(year - 16);
      year_eighteenth = new Date(year_eighteenth).getFullYear();

      var year_nineteenth = now_timer.setFullYear(year - 17);
      year_nineteenth = new Date(year_nineteenth).getFullYear();

      var year_twentieth = now_timer.setFullYear(year - 18);
      year_twentieth = new Date(year_twentieth).getFullYear();

      var year_thirteenth = null;


      console.log(year_second)
      var car_data_item = {
        year: year,
        data: []
      }
      var car_data_item_second = {
        year: year_second,
        data: []
      }
      var car_data_item_third = {
        year: year_third,
        data: []
      }

      var car_data_item_fourth = {
        year: year_fourth,
        data: []
      }
      var car_data_item_fiveth = {
        year: year_fiveth,
        data: []
      }
      var car_data_item_sixth = {
        year: year_sixth,
        data: []
      }
      var car_data_item_seventh = {
        year: year_seventh,
        data: []
      }
      var car_data_item_eighth = {
        year: year_eighth,
        data: []
      }
      var car_data_item_ninth = {
        year: year_ninth,
        data: []
      }
      var car_data_item_tenth = {
        year: year_tenth,
        data: []
      }
      var car_data_item_eleventh = {
        year: year_eleventh,
        data: []
      }
      var car_data_item_twelfth = {
        year: year_twelfth,
        data: []
      }
      var car_data_item_thirteenth = {
        year: year_thirteenth,
        data: []
      }

      var car_data_item_fourteenth = {
        year: year_fourteenth,
        data: []
      }
      var car_data_item_fifteenth = {
        year: year_fifteenth,
        data: []
      }
      var car_data_item_sixteenth = {
        year: year_sixteenth,
        data: []
      }
      var car_data_item_seventeenth = {
        year: year_seventeenth,
        data: []
      }
      var car_data_item_eighteenth = {
        year: year_eighteenth,
        data: []
      }
      var car_data_item_nineteenth = {
        year: year_nineteenth,
        data: []
      }
      var car_data_item_twentieth = {
        year: year_twentieth,
        data: []
      }
      car_data.push(car_data_item)
      car_data.push(car_data_item_second)
      car_data.push(car_data_item_third)
      car_data.push(car_data_item_fourth)
      car_data.push(car_data_item_fiveth)
      car_data.push(car_data_item_sixth)
      car_data.push(car_data_item_seventh)
      car_data.push(car_data_item_eighth)
      car_data.push(car_data_item_ninth)
      car_data.push(car_data_item_tenth)
      car_data.push(car_data_item_eleventh)
      car_data.push(car_data_item_twelfth)
      car_data.push(car_data_item_thirteenth)
      car_data.push(car_data_item_fourteenth)
      car_data.push(car_data_item_fifteenth)
      car_data.push(car_data_item_sixteenth)
      car_data.push(car_data_item_seventeenth)
      car_data.push(car_data_item_eighteenth)
      car_data.push(car_data_item_nineteenth)
      car_data.push(car_data_item_twentieth)

      console.log("car_data", car_data)

      for (let i = 0; i < car_list.length; i++) {
        if (car_list[i].yeartype == year) {
          car_data[0].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_second) {
          car_data[1].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_third) {
          car_data[2].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fourth) {
          car_data[3].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fiveth) {
          car_data[4].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_sixth) {
          car_data[5].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_seventh) {
          car_data[6].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighth) {
          car_data[7].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_ninth) {
          car_data[8].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_tenth) {
          car_data[9].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eleventh) {
          car_data[10].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_twelfth) {
          car_data[11].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_thirteenth) {
          car_data[12].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fourteenth) {
          car_data[13].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fifteenth) {
          car_data[14].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_sixteenth) {
          car_data[15].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_seventeenth) {
          car_data[16].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighteenth) {
          car_data[17].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighteenth) {
          car_data[18].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_nineteenth) {
          car_data[19].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_twentieth) {
          car_data[20].data.push(car_list[i])
        }
      }
      console.log("car_data", car_data)
      this.setData({
        car_data: car_data
      })

    }, screening_cars, token, method, params, url_id)



    
    
   
    this.setData({
      gear_index: index
    })

  },
  //选择排量筛选
  select_displacement(e) {
    var index = e.currentTarget.dataset.index;
    var displacement = this.data.car_info.displacement;//排量列表
    this.data.select_displacement_content = displacement[index] //排量
    var geartype = this.data.geartype;
    if (geartype=="自动"){
      geartype=1;
    }
    if (geartype=="手动"){
      geartype=2;
    }
    
    var gear_index = this.data.gear_index;//手自动挡index
    console.log("gear_index", gear_index)
    var parentid = this.data.parentid;
    var screening_cars = app.ul.screening_cars;
    var token=wx.getStorageSync("token");
    var method='GET';
    var params="";
    var url_id = "?parentid=" + parentid + "&displacement=" + displacement[index] + "&geartype=" + geartype
    app.requestData(res=>{
      console.log(res)

      var car_list =res.data.data;
      var car_data=[];
      var now_timer = new Date();
      var year = now_timer.getFullYear();
      var year_second = now_timer.setFullYear(year - 1);
      year_second = new Date(year_second).getFullYear();

      var year_third = now_timer.setFullYear(year - 2);
      year_third = new Date(year_third).getFullYear();

      var year_fourth = now_timer.setFullYear(year - 3);
      year_fourth = new Date(year_fourth).getFullYear();

      var year_fiveth = now_timer.setFullYear(year - 4);
      year_fiveth = new Date(year_fiveth).getFullYear();

      var year_sixth = now_timer.setFullYear(year - 5);
      year_sixth = new Date(year_sixth).getFullYear();

      var year_seventh = now_timer.setFullYear(year - 6);
      year_seventh = new Date(year_seventh).getFullYear();

      var year_eighth = now_timer.setFullYear(year - 7);
      year_eighth = new Date(year_eighth).getFullYear();

      var year_ninth = now_timer.setFullYear(year - 8);
      year_ninth = new Date(year_ninth).getFullYear();


      var year_tenth = now_timer.setFullYear(year - 9);
      year_tenth = new Date(year_tenth).getFullYear();


      var year_eleventh = now_timer.setFullYear(year - 10);
      year_eleventh = new Date(year_eleventh).getFullYear();

      var year_twelfth = now_timer.setFullYear(year - 11);
      year_twelfth = new Date(year_twelfth).getFullYear();


      var year_fourteenth = now_timer.setFullYear(year - 12);
      year_fourteenth = new Date(year_fourteenth).getFullYear();

      var year_fifteenth = now_timer.setFullYear(year - 13);
      year_fifteenth = new Date(year_fifteenth).getFullYear();

      var year_sixteenth = now_timer.setFullYear(year - 14);
      year_sixteenth = new Date(year_sixteenth).getFullYear();

      var year_seventeenth = now_timer.setFullYear(year - 15);
      year_seventeenth = new Date(year_seventeenth).getFullYear();

      var year_eighteenth = now_timer.setFullYear(year - 16);
      year_eighteenth = new Date(year_eighteenth).getFullYear();

      var year_nineteenth = now_timer.setFullYear(year - 17);
      year_nineteenth = new Date(year_nineteenth).getFullYear();

      var year_twentieth = now_timer.setFullYear(year - 18);
      year_twentieth = new Date(year_twentieth).getFullYear();

      var year_thirteenth = null;


      console.log(year_second)
      var car_data_item = {
        year: year,
        data: []
      }
      var car_data_item_second = {
        year: year_second,
        data: []
      }
      var car_data_item_third = {
        year: year_third,
        data: []
      }

      var car_data_item_fourth = {
        year: year_fourth,
        data: []
      }
      var car_data_item_fiveth = {
        year: year_fiveth,
        data: []
      }
      var car_data_item_sixth = {
        year: year_sixth,
        data: []
      }
      var car_data_item_seventh = {
        year: year_seventh,
        data: []
      }
      var car_data_item_eighth = {
        year: year_eighth,
        data: []
      }
      var car_data_item_ninth = {
        year: year_ninth,
        data: []
      }
      var car_data_item_tenth = {
        year: year_tenth,
        data: []
      }
      var car_data_item_eleventh = {
        year: year_eleventh,
        data: []
      }
      var car_data_item_twelfth = {
        year: year_twelfth,
        data: []
      }
      var car_data_item_thirteenth = {
        year: year_thirteenth,
        data: []
      }

      var car_data_item_fourteenth = {
        year: year_fourteenth,
        data: []
      }
      var car_data_item_fifteenth = {
        year: year_fifteenth,
        data: []
      }
      var car_data_item_sixteenth = {
        year: year_sixteenth,
        data: []
      }
      var car_data_item_seventeenth = {
        year: year_seventeenth,
        data: []
      }
      var car_data_item_eighteenth = {
        year: year_eighteenth,
        data: []
      }
      var car_data_item_nineteenth = {
        year: year_nineteenth,
        data: []
      }
      var car_data_item_twentieth = {
        year: year_twentieth,
        data: []
      }



      car_data.push(car_data_item)
      car_data.push(car_data_item_second)
      car_data.push(car_data_item_third)
      car_data.push(car_data_item_fourth)
      car_data.push(car_data_item_fiveth)
      car_data.push(car_data_item_sixth)
      car_data.push(car_data_item_seventh)
      car_data.push(car_data_item_eighth)
      car_data.push(car_data_item_ninth)
      car_data.push(car_data_item_tenth)
      car_data.push(car_data_item_eleventh)
      car_data.push(car_data_item_twelfth)
      car_data.push(car_data_item_thirteenth)
      car_data.push(car_data_item_fourteenth)
      car_data.push(car_data_item_fifteenth)
      car_data.push(car_data_item_sixteenth)
      car_data.push(car_data_item_seventeenth)
      car_data.push(car_data_item_eighteenth)
      car_data.push(car_data_item_nineteenth)
      car_data.push(car_data_item_twentieth)


      console.log("car_data", car_data)

      for (let i = 0; i < car_list.length; i++) {
        if (car_list[i].yeartype == year) {
          car_data[0].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_second) {
          car_data[1].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_third) {
          car_data[2].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fourth) {
          car_data[3].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fiveth) {
          car_data[4].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_sixth) {
          car_data[5].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_seventh) {
          car_data[6].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighth) {
          car_data[7].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_ninth) {
          car_data[8].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_tenth) {
          car_data[9].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eleventh) {
          car_data[10].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_twelfth) {
          car_data[11].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_thirteenth) {
          car_data[12].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fourteenth) {
          car_data[13].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_fifteenth) {
          car_data[14].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_sixteenth) {
          car_data[15].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_seventeenth) {
          car_data[16].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighteenth) {
          car_data[17].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_eighteenth) {
          car_data[18].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_nineteenth) {
          car_data[19].data.push(car_list[i])
        }
        if (car_list[i].yeartype == year_twentieth) {
          car_data[20].data.push(car_list[i])
        }
      }
      console.log("car_data", car_data)
      this.setData({
        car_data: car_data
      })
      
    }, screening_cars, token, method, params, url_id)

 
    console.log("index", index)
    this.setData({
      displacement_index: index
    })
  },
  //选择车
  select_car(e){
    var car_models = e.currentTarget.dataset.car_models;//车型
    var car_price=e.currentTarget.dataset.car_price;
    var car_year=e.currentTarget.dataset.car_year;
    var geartype = e.currentTarget.dataset.geartype;
    console.log("geartype", geartype)
    
    if(geartype==1){
      geartype="自动"
    }
    if(geartype==2){
      geartype="手动"
    }
    console.log("car_models", car_models)
    var source = this.data.source;
    var car_name = this.data.car_name;
    var brand_name = this.data.brand_name;//当前品牌
    var car_info_item={
      brand_name: brand_name,
      car_brand: car_name,
      geartype: geartype,
      car_model: car_models,
      car_price:car_price, //发售价
      car_year:car_year//发售年份
    }
    console.log("car_info_item", car_info_item)
    wx.setStorageSync("car_info_item", car_info_item);
    wx.navigateBack({
      
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  arrayToHeavy(arr) {
    //过滤掉原数组中重复的数字,返回新的数组
    return arr.filter((item, index) => {
      //遍历出数组中数字第一次出现的下标,与数字所在数组的下标相比较，
      //为true就是第一次出现
      return arr.indexOf(item) === index
    })
  },
  removeRepeat(arr) {
    var obj = {};
    for (var i = 0; i < arr.length; i++) {
      // 判断当前项是否遍历过，是则删除，否存入obj以作对照
      if (obj.hasOwnProperty(arr[i])) {
        arr.splice(i, 1)
        i++;
      }
      obj[arr[i]] = i;
    }
    return arr;
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})